package com.harry.configuration.web.api;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.harry.decoupling.defi.tool.BinaryDataManager;
import com.harry.resource.inner.entity.InnerFileContent;

@Controller
@RequestMapping("/resource/innerFileContent")
public class FileContentResufulApi {

	@Autowired
	private BinaryDataManager bdm;

	@PostMapping("/post")
	public void post(HttpServletRequest request, HttpServletResponse response, @RequestParam("file") MultipartFile file, Map<String, Object> data) throws Exception {
		InnerFileContent fileContent = new InnerFileContent();
		fileContent.setId(bdm.write(file.getInputStream()));
		data.put("data", fileContent);
	};
}